<template>
  <div class="yaoqing_wrap">
    <div class="titles">
      <i @click="goBack" class="iconfont fl">&#xe624;</i>
      <h3 class="title-h3">邀请码</h3>
    </div>
    <div class="yaoqing_bottom">
      <div class="yaoqing_1">邀请好友使用，即可获得红包代金券</div>
      <div class="yaoqing_2">发送邀请码给好友使用，好友成功支付订单后，邀请者即可获得不同数额的红包代金券</div>
      <div class="yaoqing_3">我的邀请码
        <span>{{invitation}}</span>
      </div>
      <div class="yaoqing_4">分享邀请码</div>
    </div>
  </div>
</template>

<script>
import {queryInvitationCode} from '../../api/person.js'
export default {
  data () {
    return {
      userNum: '',
      invitation: ''
    }
  },
  mounted () {
    let that = this
    mui.init({
      keyEventBind: {
        backbutton: true  //关闭back按键监听
      }
    })
    mui.back = function () {
      that.$router.push({
        path: '/index/person'
      })
      error
    }
  },
  methods: {
    goBack () {
      this.$router.go(-1)
    },
    async queryInvitationCode () {
      try {
        let data = await queryInvitationCode({userNum: this.userNum})
        this.invitation = data.data.invitationCode
      } catch (err) {
        console.log(err)
      }
    }
  },
  created: function () {
    this.userNum = this.$store.state.userNum
    this.queryInvitationCode()
  }
}
</script>

<style scoped>
  .titles{
    height: 1.6rem;
    position: fixed;
    z-index: 10;
    box-sizing: border-box;
    left: 0;
    right: 0;
    top: 0;
    background: #fff;
  }
  .title-h3{
    text-align: center;
    line-height: 1.6rem;
    font-size: .8rem;
  }
  .iconfont{
    line-height: 1.6rem;
    left: .5rem;
    font-size: .8rem;
    position: absolute;
  }
  .yaoqing_wrap{
    background-image: url(../../../static/yaoqing_bg.png)!important;
    background-repeat: no-repeat!important;
    background-size: 100% 100%!important;
    background-position: left top!important;
    height: 100%;
  }
  .yaoqing_bottom{
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    color: #fff;
  }
  .yaoqing_1{
    font-size: .7rem;
    font-weight: 600;
  }
  .yaoqing_2{
    font-size: .55rem;
    margin-top: .8rem;
    margin-left: 10%;
    margin-right: 10%;
  }
  .yaoqing_3{
    font-size: .85rem;
    border-bottom: 1px solid #fff;
    margin-left: 10%;
    margin-right: 10%;
    padding-bottom: .2rem;
    text-align: left;
    margin-top: .8rem;
    margin-bottom: 1.5rem;
  }
  .yaoqing_3 span{
    margin-left: .5rem;
  }
  .yaoqing_4{
    margin: .5rem 6%;
    background: #fff;
    border-radius: 1rem;
    color: #e94c75;
    font-size: .7rem;
    height: 1.5rem;
    line-height: 1.5rem;
    font-weight: 600;
  }
</style>
